<template>
  <div class="wrap">
    <div v-for='game in games' :key='game.GAME_ID' v-if='game.GAME_STEP != "5" && game.GAME_ID' @click='gotoDetail(game)'>
      <game-item :game='game' v-if='isOldGame(game)'></game-item>
      <game-item-new :game='game' v-else></game-item-new>
      <div class="divide"></div>
    </div>
	</div>
</template>
<style lang='less' scoped>
.wrap{
  background: #fff;
  .divide{
    border-bottom: dashed 1px #a1a1a1;
    margin: 0 8%;
  }
}

</style>
<script>
import RemoteDAO from 'common/remoteDAO'
import GameItem from 'components/game/gamelist/GameItem'
import GameItemNew from 'components/game/gamelist/GameItemV2'
export default{
  components:{GameItem, GameItemNew},
	data(){
		return {
			games:[],
			noData: true
		}
	},
	created(){
		this.getHSGames();
	},
	methods:{
    isOldGame (game) {
      if (game.JOIN_BEGIN_DATE === '' || game.JOIN_BEGIN_DATE === '0' || !game.JOIN_BEGIN_DATE) return false
      return true
    },
		gotoDetail(game){
      if (game.GAME_TYPE === 'TDS') {// 团队赛
        if (game.UP_GAME_ID !== '') { // 子团队
          this.$router.push('/team-game/team-detail?gameId=' + game.GAME_ID + '&gameTitle=' + game.UP_GAME_NAME)
        } else { // 大团队
          this.$router.push('/team-game/game-detail?gameId=' + game.GAME_ID + '&gameName=' + game.GAME_NAME)
        }
      } else { //个人PK
        this.$router.push({path: '/game/gamedetail',query:{gameId:game.GAME_ID}})
      }
		},
		getHSGames(){
			RemoteDAO.hotSearch(4, (response) =>{
        if(response.error == '0'){
          console.info('hotSearch', response)
          if(response != undefined && response.data.body != undefined && response.data.body.length > 0){
              this.games = response.data.body;
          }
        }
			});
		}
	}
}
</script>